﻿using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Extensions.Options;

namespace MagickConverter
{
    public class MagickService : IMagickService
    {
        private readonly MagickQueue _queue;
        private int Density { get; }
        private int Quality { get; }
        private string Size { get; }
        private string Root { get; }

        public MagickService(IOptions<MagickSettings> options)
        {
            _queue = new MagickQueue();
            var settings = options.Value;
            Density = settings.Density;
            Quality = settings.Quality;
            Size = settings.Size;
            Root = Path.Combine(Directory.GetCurrentDirectory(), settings.Temp);
        }

        public void Convert(Action<string> buiding, Action<Queue<string>> finished)
        {
            var task = new MagickTask(Root, Density, Quality, Size);
            task.BuidingEvent += buiding;
            task.FinishedEvent += finished;
            _queue.EnqueueTask(task);
        }



    }
}
